package leetcode;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2022-01-25 16:58
 **/
public class LeetCode1688 {

    //数学
    /*public int numberOfMatches(int n) {
        return n - 1;
    }*/

    //模拟
    public int numberOfMatches(int n) {
        int count = 0;
        while (n > 1) {
            if ((n & 1) == 1) {
                count += (n - 1) / 2;
                n -= (n - 1) / 2;
            } else {
                count += n / 2;
                n /= 2;
            }
        }

        return count;
    }

}
